package com.potenza.training.dictionary.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.dictionary.dao.HopePersonalSkillsDao;
import com.potenza.training.dictionary.entity.HopePersonalSkills;
import com.potenza.training.dictionary.server.HopePersonalSkillsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("hopePersonalSkillsServiceImpl")
public class HopePersonalSkillsServiceImpl extends ServiceImpl<HopePersonalSkillsDao, HopePersonalSkills> implements HopePersonalSkillsService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private HopePersonalSkillsDao hopePersonalSkillsDao;


    @Override
    public List<HopePersonalSkills> findAll() {
        Object hopePersonalSkills = redisTemplate.opsForValue().get("hopePersonalSkills");
        if (hopePersonalSkills==null){
            List<HopePersonalSkills> list = this.list();
            redisTemplate.opsForValue().set("hopePersonalSkills", list);
            return list;
        }

        return (List<HopePersonalSkills>)hopePersonalSkills;
    }
}